package ins.undwrt;
import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
//@EnableDiscoveryClient
//@EnableEurekaClient
//@EnableCircuitBreaker 
// Spring 组件包扫描路径
@ComponentScan(basePackages = "ins")
public class MiscServiceApplication {

	public static void main(String[] args) {
		new SpringApplicationBuilder(MiscServiceApplication.class).web(true).run(args);
	}

	@LoadBalanced
	@Bean(name="restTemplate")
	RestTemplate restTemplate() {
		RestTemplate restTemplate = new RestTemplate();
		List<HttpMessageConverter<?>> messageConverters = new ArrayList<HttpMessageConverter<?>>();
		MappingJackson2HttpMessageConverter mappingJackson2http = new MappingJackson2HttpMessageConverter();
		StringHttpMessageConverter stringHttp = new StringHttpMessageConverter();
		messageConverters.add(mappingJackson2http);
		messageConverters.add(stringHttp);
		restTemplate.setMessageConverters(messageConverters);
		return restTemplate;
	}
//	@Bean  
//    public FilterRegistrationBean  filterRegistrationBean() {  
//        FilterRegistrationBean registrationBean = new FilterRegistrationBean();  
//        SessionFilter sessionFilter = new SessionFilter();  
//        registrationBean.setFilter(sessionFilter);  
//        List<String> urlPatterns = new ArrayList<String>();  
//        urlPatterns.add("/*");
//        Map<String,String> params = new HashMap<String,String>();
//        params.put("excludedPages", "/jwt/auth");
//        registrationBean.setInitParameters(params);
//        registrationBean.setUrlPatterns(urlPatterns);
//        return registrationBean;  
//    }
}
